IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tr_Project_Ins]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[tr_Project_Ins]
GO

CREATE PROCEDURE [dbo].[tr_Project_Ins]
	@ProjectName VARCHAR(MAX),
	@ProjectDescription VARCHAR(MAX),
	@UserId UNIQUEIDENTIFIER,
	@Email VARCHAR(MAX)
AS

DECLARE @ProjectId UNIQUEIDENTIFIER
SET @ProjectId = NEWID()

INSERT INTO tr_Project (ProjectId, Name, [Description], ActiveInd) VALUES (@ProjectId, @ProjectName, @ProjectDescription, 0)
INSERT INTO tr_ProjectUser (ProjectId, UserId) VALUES (@ProjectId, @UserId)

DECLARE @EmailAddress VARCHAR(MAX)
SET @EmailAddress = @email

INSERT INTO tr_ProjectSettings (ProjectId, ProjectEmail) VALUES (@ProjectId, @EmailAddress)
